<?php

namespace App\Http\Resources\Api;

use App\Models\Coach;
use App\Models\Tenant;
use Illuminate\Http\Resources\Json\JsonResource;

class CoachOrderResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        $tenant = Tenant::find($this->tenant_id);
        $coach = Coach::find($this->coach_id);
        return [
            'id'=>$this->id,
            'tenant_name' => $tenant->name,
            'coach_name' => $coach->realname,
            'order_sn' => $this->order_sn,
            'sale_num' => $this->sale_num,
            'transaction_id' => $this->transaction_id,
            'openid' => $this->openid,
            'body' => $this->body,
            'total_fee' => $this->total_fee,
            'is_paid' => (boolean)$this->is_paid,
            'paid_time' => $this->paid_time,
            'created_at'=>(string)$this->created_at,
            'updated_at'=>(string)$this->updated_at
        ];
    }
}
